{include file="public/header296" /}
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">省</label>
    <div class="layui-input-inline">
      <select name="province_id" lay-filter="province_id" lay-verify="required">
        <option value="0">请选择省</option>
        {volist name="data['province_list']" id="vo"}
        <option value="{$vo.id}" {eq name="data.province_id" value="$vo.id"}selected{/eq}>{$vo.title_name}</option>
        {/volist}
      </select>
    </div>
  </div>
  {notempty name="data['city_list']"}
  <div class="layui-form-item">
    <label class="layui-form-label">市</label>
    <div class="layui-input-inline">
      <select name="parent_id" id="parent_id" lay-verify="required">
        <option value="0">请选择市</option>
        {volist name="data['city_list']" id="vo"}
        <option value="{$vo.id}" {eq name="data.parent_id" value="$vo.id"}selected{/eq}>{$vo.title_name}</option>
        {/volist}
      </select>
    </div>
  </div>
  {/notempty}
  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-inline">
      <input type="text" lay-verify="required" name="title_name" value="{$data.title_name|default=''}" autocomplete="on" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item layui-hide">
    <input type="hidden" name="id" id="id" value="{$data.id|default=''}" />
    <input type="button" lay-submit lay-filter="Lay-app-form-edit" id="Lay-app-form-edit" value="编辑">
  </div>
</div>
<script>
layui.use(['layer','form'], function(){
  var $ = layui.$
       , form = layui.form;

  // 获取主栏目下的子栏目
  form.on('select(province_id)',function(obj){
    var province_id = obj.value;
    $.ajax({
      url:"{:url('city/getCitys')}",
      type: "POST",
      dataType: "JSON",
      data: {province_id: province_id},
      success:function(data){
        var proHtml = '';
        for(var o in data){
          proHtml += '<option value="' + data[o].id +  '">' + data[o].title_name + '</option>';
        }
        $('#parent_id').html(proHtml);
        form.render();
      },
      error:function(){
        alert("error");
      }
    })
  });
})
</script>
{include file="public/footer" /}